---
title: 配置Java在Emacs下的开发环境
tags:
  - emacs
  - java
  - programming
categories:
  - 效率
layout: post
---


<div id="outline-container-org99e0dcd" class="outline-2">
<h2 id="org99e0dcd">简介</h2>
<div class="outline-text-2" id="text-org99e0dcd">
<p>
这篇主要讲解利用Emacs进行Java的开发所需要的相关配置，主要依靠emacs的Language Server Protocol (LSP)包来辅助编写Java。本文大量利用use-package来安装相关的包。
</p>
</div>
</div>
<div id="outline-container-org3112e1e" class="outline-2">
<h2 id="org3112e1e">安装</h2>
<div class="outline-text-2" id="text-org3112e1e">
<p>
下文中 <kbd>EMACS_DIR</kbd> 是初始化 <span class="underline">init.el</span> 所在的位置，默认所在 <b>.emacs.d</b> 。你也可以使用emacs -Q -l /you/path/init.el。
</p>
</div>

<div id="outline-container-org7c37b66" class="outline-3">
<h3 id="org7c37b66">安装包的仓库</h3>
<div class="outline-text-3" id="text-org7c37b66">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">require</span> '<span style="color: #AF005F;">package</span>)

(<span style="color: #D70000;">setq</span> package-archives '((<span style="color: #005F00;">"melpa"</span> . <span style="color: #005F00;">"https://melpa.org/packages/"</span>)
                         (<span style="color: #005F00;">"elpa"</span> . <span style="color: #005F00;">"https://elpa.gnu.org/packages/"</span>)
                         (<span style="color: #005F00;">"org"</span> . <span style="color: #005F00;">"https://orgmode.org/elpa/"</span>)
                         ))


(package-initialize)

                                        <span style="color: #4E4E4E; font-style: italic;">; </span><span style="color: #4E4E4E; font-style: italic;">Fetch the list of packages available</span>
(<span style="color: #D70000;">unless</span> package-archive-contents (package-refresh-contents))

                                        <span style="color: #4E4E4E; font-style: italic;">; </span><span style="color: #4E4E4E; font-style: italic;">Install use-package</span>
(<span style="color: #D70000;">setq</span> package-list '(<span style="color: #D70000;">use-package</span>))
(<span style="color: #D70000;">dolist</span> (package package-list)
  (<span style="color: #D70000;">unless</span> (package-installed-p package) (package-install package)))

</pre>
</div>
<p>
国内访问慢可以换成清华的源:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">setq</span> package-archives
      '((<span style="color: #005F00;">"gnu"</span>          . <span style="color: #005F00;">"http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/"</span>)
        (<span style="color: #005F00;">"melpa"</span>        . <span style="color: #005F00;">"http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/"</span>)
        (<span style="color: #005F00;">"org"</span>          . <span style="color: #005F00;">"http://mirrors.tuna.tsinghua.edu.cn/elpa/org/"</span>)))
</pre>
</div>
</div>
</div>


<div id="outline-container-orgf37983b" class="outline-3">
<h3 id="orgf37983b">安装环境</h3>
<div class="outline-text-3" id="text-orgf37983b">
<p>
在某些系统上emacs可能不能正确的加载环境变量，因此用 <kbd>exec-path-from</kbd> 来初始化。
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">exec-path-from-shell</span> <span style="color: #1F55A0;">:ensure</span> t)
(exec-path-from-shell-initialize)
</pre>
</div>
</div>
</div>

<div id="outline-container-orga4a1529" class="outline-3">
<h3 id="orga4a1529">为操作系统指定Java需要的环境变量如 <kbd>JAVA_HOME</kbd> 等</h3>
<div class="outline-text-3" id="text-orga4a1529">
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Load platform specific variables using specific files. E.g linux.el.</span>
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Make necessary changes as needed</span>
(<span style="color: #D70000;">cond</span> ((eq system-type 'windows-nt) (load (concat EMACS_DIR <span style="color: #005F00;">"windows"</span>)))
      ((eq system-type 'gnu/linux) (load (concat EMACS_DIR <span style="color: #005F00;">"linux"</span>)))
      ((eq system-type 'darwin) (load (concat EMACS_DIR <span style="color: #005F00;">"mac"</span>)))
      (t (load-library <span style="color: #005F00;">"default"</span>)))
</pre>
</div>

<p>
假设你的系统所linux, 那么你需要在linux.el中设在相关的环境，例如：
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setenv <span style="color: #005F00;">"JAVA_HOME"</span> <span style="color: #005F00;">"/usr/lib/jvm/java-11-openjdk-amd64"</span>)
</pre>
</div>
</div>
</div>

<div id="outline-container-org3575e16" class="outline-3">
<h3 id="org3575e16">一些基本的配置</h3>
<div class="outline-text-3" id="text-org3575e16">
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Disable annoying ring-bell when backspace key is pressed in certain situations</span>
(<span style="color: #D70000;">setq</span> ring-bell-function 'ignore)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Disable scrollbar and toolbar</span>
(scroll-bar-mode -1)
(tool-bar-mode -1)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Set language environment to UTF-8</span>
(set-language-environment <span style="color: #005F00;">"UTF-8"</span>)
(set-default-coding-systems 'utf-8)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Longer whitespace, otherwise syntax highlighting is limited to default column</span>
(<span style="color: #D70000;">setq</span> whitespace-line-column 1000)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Enable soft-wrap</span>
(global-visual-line-mode 1)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Maintain a list of recent files opened</span>
(recentf-mode 1)
(<span style="color: #D70000;">setq</span> recentf-max-saved-items 50)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Move all the backup files to specific cache directory</span>
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">This way you won't have annoying temporary files starting with ~(tilde) in each directory</span>
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Following setting will move temporary files to specific folders inside cache directory in EMACS_DIR</span>

(<span style="color: #D70000;">setq</span> user-cache-directory (concat EMACS_DIR <span style="color: #005F00;">"cache"</span>))
(<span style="color: #D70000;">setq</span> backup-directory-alist `((<span style="color: #005F00;">"."</span> . ,(expand-file-name <span style="color: #005F00;">"backups"</span> user-cache-directory)))
      url-history-file (expand-file-name <span style="color: #005F00;">"url/history"</span> user-cache-directory)
      auto-save-list-file-prefix (expand-file-name <span style="color: #005F00;">"auto-save-list/.saves-"</span> user-cache-directory)
      projectile-known-projects-file (expand-file-name <span style="color: #005F00;">"projectile-bookmarks.eld"</span> user-cache-directory))

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Org-mode issue with src block not expanding</span>
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">This is a fix for bug in org-mode where &lt;s TAB does not expand SRC block</span>
(<span style="color: #D70000;">when</span> (version&lt;= <span style="color: #005F00;">"9.2"</span> (org-version))
  (<span style="color: #D70000;">require</span> '<span style="color: #AF005F;">org-tempo</span>))

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Coding specific setting</span>

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Automatically add ending brackets and braces</span>
(electric-pair-mode 1)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Make sure tab-width is 4 and not 8</span>
(<span style="color: #D70000;">setq-default</span> tab-width 4)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">Highlight matching brackets and braces</span>
(show-paren-mode 1)
</pre>
</div>
</div>
</div>
</div>

<div id="outline-container-org4b050a3" class="outline-2">
<h2 id="org4b050a3">外观</h2>
<div class="outline-text-2" id="text-org4b050a3">
</div>
<div id="outline-container-orge28638a" class="outline-3">
<h3 id="orge28638a">主题</h3>
<div class="outline-text-3" id="text-orge28638a">
<p>
这里推荐 <b>doom-themes</b> 包。
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">doom-themes</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:init</span>
    (load-theme 'doom-palenight t))
</pre>
</div>
</div>
</div>

<div id="outline-container-org60ef846" class="outline-3">
<h3 id="org60ef846">字体</h3>
<div class="outline-text-3" id="text-org60ef846">
<p>
linux下推荐使用 <b>Hack</b> 字体.编程看起来比较舒服.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">
(<span style="color: #D70000;">defun</span> <span style="color: #AF8700;">my--set-font</span> (<span style="color: #1F55A0;">&amp;optional</span> frame)
  (<span style="color: #D70000;">with-selected-frame</span> (<span style="color: #D70000;">or</span> frame (selected-frame))
    (<span style="color: #D70000;">cond</span>
      <span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">&#19979;&#38754;&#26159;Linux&#30340;&#37197;&#32622;&#65292;&#36947;&#29702;&#31867;&#20284;&#12290;</span>
      ((eq system-type 'gnu/linux) (<span style="color: #D70000;">progn</span>
                                     (set-face-attribute
                                      'default nil <span style="color: #1F55A0;">:font</span> <span style="color: #005F00;">"Hack"</span> <span style="color: #1F55A0;">:width</span> 'semi-condensed)
                                     (<span style="color: #D70000;">dolist</span> (charset '(kana han symbol cjk-misc bopomofo))
                                       (set-fontset-font <span style="color: #005F00;">"fontset-default"</span>
                                                         charset (font-spec <span style="color: #1F55A0;">:name</span> <span style="color: #005F00;">"Noto Sans Mono CJK SC"</span>)))
                                     ))
      <span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">&#19979;&#38754;&#26159;MacOS&#30340;&#37197;&#32622;&#65292;&#36947;&#29702;&#31867;&#20284;&#12290;</span>
      ((eq system-type 'darwin) (<span style="color: #D70000;">progn</span>
                                  (set-face-attribute
                                   'default nil <span style="color: #1F55A0;">:font</span> <span style="color: #005F00;">"Manaco"</span>)
                                  (<span style="color: #D70000;">dolist</span> (charset '(kana han symbol cjk-misc bopomofo))
                                    (set-fontset-font <span style="color: #005F00;">"fontset-default"</span>
                                                      charset (font-spec <span style="color: #1F55A0;">:name</span> <span style="color: #005F00;">"Hiragino Sans GB"</span>)))))))
  )
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">&#36816;&#34892;&#19968;&#19979;&#31435;&#21363;&#35774;&#32622;&#23383;&#20307;&#12290;</span>
<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">(add-hook 'after-init-hook 'my--set-font)</span>
(my--set-font)

<span style="color: #4E4E4E; font-style: italic;">;; </span><span style="color: #4E4E4E; font-style: italic;">&#23545;&#20110;&#26032;&#24314;&#30340;frame&#24212;&#29992;&#35774;&#32622;&#12290;</span>
(add-hook 'after-make-frame-functions #'my--set-font)
</pre>
</div>
</div>
</div>

<div id="outline-container-orgdfc0f43" class="outline-3">
<h3 id="orgdfc0f43">关闭代码补全的ansi color</h3>
<div class="outline-text-3" id="text-orgdfc0f43">
<div class="org-src-container">
<pre class="src src-emacs-lisp">
(<span style="color: #D70000;">defun</span> <span style="color: #AF8700;">my/ansi-colorize-buffer</span> ()
  (<span style="color: #D70000;">let</span> ((buffer-read-only nil))
    (ansi-color-apply-on-region (point-min) (point-max))))

(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">ansi-color</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:config</span>
    (add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)
    )
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgda9c55d" class="outline-2">
<h2 id="orgda9c55d">比较常用的包</h2>
<div class="outline-text-2" id="text-orgda9c55d">
</div>
<div id="outline-container-org2a3ef04" class="outline-3">
<h3 id="org2a3ef04">Projectile</h3>
<div class="outline-text-3" id="text-org2a3ef04">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">projectile</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:init</span> (projectile-mode +1)
    <span style="color: #1F55A0;">:config</span>
    (define-key projectile-mode-map (kbd <span style="color: #005F00;">"C-c p"</span>) 'projectile-command-map)
    )
</pre>
</div>
</div>
</div>

<div id="outline-container-org0343eb6" class="outline-3">
<h3 id="org0343eb6">Avy Goto</h3>
<div class="outline-text-3" id="text-org0343eb6">
<p>
快速的跳到特定的字符,增加编程效率.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">avy</span>
    <span style="color: #1F55A0;">:ensure</span> t)
</pre>
</div>
</div>
</div>

<div id="outline-container-which_key" class="outline-3">
<h3 id="which_key">Which Key</h3>
<div class="outline-text-3" id="text-which_key">
<p>
按键提示功能.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">which-key</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:init</span>
    (which-key-mode)
    )
</pre>
</div>
</div>
</div>
</div>

<div id="outline-container-orge51a176" class="outline-2">
<h2 id="orge51a176">Language Server Protocol (LSP)</h2>
<div class="outline-text-2" id="text-orge51a176">
<p>
下面安装LSP相关的包.
</p>
</div>

<div id="outline-container-org3400bdc" class="outline-3">
<h3 id="org3400bdc">Company</h3>
<div class="outline-text-3" id="text-org3400bdc">
<p>
代码补全.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">company</span> <span style="color: #1F55A0;">:ensure</span> t)
</pre>
</div>
</div>
</div>

<div id="outline-container-orge3ec213" class="outline-3">
<h3 id="orge3ec213">Yasnippet</h3>
<div class="outline-text-3" id="text-orge3ec213">
<p>
完成模板,帮助快速编写代码.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">yasnippet</span> <span style="color: #1F55A0;">:config</span> (yas-global-mode))
(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">yasnippet-snippets</span> <span style="color: #1F55A0;">:ensure</span> t)
</pre>
</div>

<p>
E.g. 在java mode下如果你按下 <kbd>pr</kbd> 接着按 <kbd>&lt;TAB&gt;</kbd> 就会完成 <kbd>System.out.println("text");</kbd>
可以用 <kbd>yas-describe-tables</kbd> 查看snippet 模板
也可以用 <kbd>yas-new-snippet</kbd> 创建自己的snippet.
</p>
</div>
</div>

<div id="outline-container-org6a72c7c" class="outline-3">
<h3 id="org6a72c7c">FlyCheck</h3>
<div class="outline-text-3" id="text-org6a72c7c">
<p>
方便检查错误
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">flycheck</span> <span style="color: #1F55A0;">:ensure</span> t <span style="color: #1F55A0;">:init</span> (global-flycheck-mode))
</pre>
</div>
</div>
</div>

<div id="outline-container-org572b83b" class="outline-3">
<h3 id="org572b83b">Dap Mode</h3>
<div class="outline-text-3" id="text-org572b83b">
<p>
Emacs Debug Adapter Protocol aka DAP Mode. 方便调试代码.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">dap-mode</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:after</span> (lsp-mode)
    <span style="color: #1F55A0;">:functions</span> dap-hydra/nil
    <span style="color: #1F55A0;">:config</span>
    (<span style="color: #D70000;">require</span> '<span style="color: #AF005F;">dap-java</span>)
    <span style="color: #1F55A0;">:bind</span> (<span style="color: #1F55A0;">:map</span> lsp-mode-map
                (<span style="color: #005F00;">"&lt;f5&gt;"</span> . dap-debug)
                (<span style="color: #005F00;">"M-&lt;f5&gt;"</span> . dap-hydra))
    <span style="color: #1F55A0;">:hook</span> ((dap-mode . dap-ui-mode)
           (dap-session-created . (<span style="color: #D70000;">lambda</span> (<span style="color: #1F55A0;">&amp;_rest</span>) (dap-hydra)))
           (dap-terminated . (<span style="color: #D70000;">lambda</span> (<span style="color: #1F55A0;">&amp;_rest</span>) (dap-hydra/nil)))))

(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">dap-java</span> <span style="color: #1F55A0;">:ensure</span> nil)
</pre>
</div>
</div>
</div>

<div id="outline-container-org8e2bd13" class="outline-3">
<h3 id="org8e2bd13">Treemacs</h3>
<div class="outline-text-3" id="text-org8e2bd13">
<p>
方便查看错误信息.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">lsp-treemacs</span>
    <span style="color: #1F55A0;">:after</span> (lsp-mode treemacs)
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:commands</span> lsp-treemacs-errors-list
    <span style="color: #1F55A0;">:bind</span> (<span style="color: #1F55A0;">:map</span> lsp-mode-map
                (<span style="color: #005F00;">"M-9"</span> . lsp-treemacs-errors-list)))

(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">treemacs</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:commands</span> (treemacs)
    <span style="color: #1F55A0;">:after</span> (lsp-mode))
</pre>
</div>
</div>
</div>

<div id="outline-container-orgf419fa7" class="outline-3">
<h3 id="orgf419fa7">LSP UI</h3>
<div class="outline-text-3" id="text-orgf419fa7">
<p>
LSP 环境下的 UI 配置.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">lsp-ui</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:after</span> (lsp-mode)
    <span style="color: #1F55A0;">:bind</span> (<span style="color: #1F55A0;">:map</span> lsp-ui-mode-map
                ([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
                ([remap xref-find-references] . lsp-ui-peek-find-references))
    <span style="color: #1F55A0;">:init</span> (<span style="color: #D70000;">setq</span> lsp-ui-doc-delay 1.5
                lsp-ui-doc-position 'bottom
                lsp-ui-doc-max-width 100
                ))
</pre>
</div>

<p>
<a href="https://github.com/emacs-lsp/lsp-ui/blob/master/lsp-ui-doc.el">查看其他参数设定</a>
</p>
</div>
</div>

<div id="outline-container-org158df1b" class="outline-3">
<h3 id="org158df1b">安装 LSP Package</h3>
<div class="outline-text-3" id="text-org158df1b">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">lsp-mode</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:hook</span> (
           (lsp-mode . lsp-enable-which-key-integration)
           (java-mode . #'lsp-deferred)
           )
    <span style="color: #1F55A0;">:init</span> (<span style="color: #D70000;">setq</span>
           lsp-keymap-prefix <span style="color: #005F00;">"C-c l"</span>              <span style="color: #4E4E4E; font-style: italic;">; </span><span style="color: #4E4E4E; font-style: italic;">this is for which-key integration documentation, need to use lsp-mode-map</span>
           lsp-enable-file-watchers nil
           read-process-output-max (* 1024 1024)  <span style="color: #4E4E4E; font-style: italic;">; </span><span style="color: #4E4E4E; font-style: italic;">1 mb</span>
           lsp-completion-provider <span style="color: #1F55A0;">:capf</span>
           lsp-idle-delay 0.500
           )
    <span style="color: #1F55A0;">:config</span>
    (<span style="color: #D70000;">setq</span> lsp-intelephense-multi-root nil) <span style="color: #4E4E4E; font-style: italic;">; </span><span style="color: #4E4E4E; font-style: italic;">don't scan unnecessary projects</span>
    (<span style="color: #D70000;">with-eval-after-load</span> 'lsp-intelephense
      (<span style="color: #D70000;">setf</span> (lsp--client-multi-root (gethash 'iph lsp-clients)) nil))
    (define-key lsp-mode-map (kbd <span style="color: #005F00;">"C-c l"</span>) lsp-command-map)
    )
</pre>
</div>

<p>
你能够通过 <kbd>C-c l s s</kbd> 开启 LSP server.查看<a href="https://emacs-lsp.github.io/lsp-mode/page/performance/">更多介绍</a>.
</p>
</div>
</div>

<div id="outline-container-orgc461ced" class="outline-3">
<h3 id="orgc461ced">LSP Java</h3>
<div class="outline-text-3" id="text-orgc461ced">
<p>
lsp Java 语言的客户端. 里面有许多方便java编程的命令.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #D70000;">use-package</span> <span style="color: #AF005F;">lsp-java</span>
    <span style="color: #1F55A0;">:ensure</span> t
    <span style="color: #1F55A0;">:config</span> (add-hook 'java-mode-hook 'lsp))
</pre>
</div>
</div>
</div>
</div>

<div id="outline-container-org62e88c8" class="outline-2">
<h2 id="org62e88c8">总结</h2>
<div class="outline-text-2" id="text-org62e88c8">
<p>
获取更多关于lsp-java的<a href="https://github.com/emacs-lsp/lsp-java#supported-commands">支持</a>大多数情况下利用<a href="#which_key">which key</a>的提示就可以获取相
关的信息, 当按下 <kbd>C-c l</kbd> 时就会提示LSP相关的信息.
</p>
</div>
</div>
